package com.hpe.fastfood.filter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

public class SessionFilter extends HandlerInterceptorAdapter {

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		HttpSession session = request.getSession();
		if (session.getAttribute("loginBussiness") == null && session.getAttribute("name") == null) {
			request.getRequestDispatcher("/login/toLogin").forward(request, response);
			return false;
		} else {
			return true;
		}
	}

}
